home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / ch1 / hello.C next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.0 KB  |  64 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ////////////////////////////////////////////////////////
  22. // hello.C, Hello World using C++ and Motif
  23. ////////////////////////////////////////////////////////
  24. #include <Xm/Xm.h>
  25. #include <Xm/Label.h>
  26.  
  27. #if (XlibSpecificationRelease>=5)
  28. void main ( int argc, char **argv )
  29. #else
  30. void main ( unsigned int argc, char **argv )
  31. #endif
  32. {
  33.     Widget       label, toplevel;
  34.     XtAppContext app;
  35.     XmString     xmstr;
  36.     Arg          args[10];
  37.     int          n;
  38.     
  39.     // Initialize the Intrinsics
  40.     
  41.     toplevel = XtAppInitialize ( &app, "Hello", NULL, 0, 
  42.                 &argc, argv, NULL, NULL, 0 );
  43.     
  44.     // Create a compound string to display the Hello message
  45.     
  46.     xmstr = XmStringCreateSimple ( "Hello World" );
  47.     
  48.     // Create a label widget to display the string
  49.     
  50.     n = 0;
  51.     XtSetArg ( args[n], XmNlabelString, xmstr ); n++;
  52.     label = XtCreateManagedWidget ( "label", xmLabelWidgetClass,
  53.                    toplevel, args, n );
  54.     
  55.     // Free the compound string when it is no longer needed.
  56.     
  57.     XmStringFree ( xmstr );
  58.     
  59.     // Realize all widgets and enter the main event loop
  60.     
  61.     XtRealizeWidget ( toplevel );
  62.     XtAppMainLoop ( app );
  63. }
  64.